package com.chixing.service.impl;

import com.chixing.mapper.OrderFlowMapper;
import com.chixing.pojo.OrderFlow;
import com.chixing.pojo.OrderFlowExample;
import com.chixing.service.FlowService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author YHB
 * @date 2021/10/21  19:50
 */
@Service
public class FlowServiceImpl implements FlowService {
    @Autowired
    private OrderFlowMapper orderFlowMapper;

    @Override
    public ServerResponse getByOrderId(Integer orderId) {
        OrderFlowExample orderFlowExample = new OrderFlowExample();
        OrderFlowExample.Criteria criteria = orderFlowExample.createCriteria();
        criteria.andOrderIdEqualTo(orderId);
        OrderFlow orderFlow = (OrderFlow) orderFlowMapper.selectByExample(orderFlowExample);
        if(orderFlow != null){
            ServerResponse.getSucccess(orderFlow);
        }
        return ServerResponse.getFail(null);
    }

    @Override
    public boolean save(OrderFlow orderFlow) {
        return orderFlowMapper.insert(orderFlow)>0;
    }
}
